﻿Parse.initialize("hoUdUTN3q4Js5lc1YFLNwRMoFiZfKKMbKpOD7E2q", "R69EMYXOUNPkY2Vh78fnayUdflscKqQoOnsmKfUI");

$(function onDocumentReady() {
    $(".btn-login-form").on("click", function onShowRegisterBtnClick() {
        var btnId = $(this).attr("id");
        var formId = "form-" + btnId.substr("btn-show-".length);
        $("form").addClass("invisible");
        $("#" + formId).removeClass("invisible");

        $("a.current").removeClass("current");
        $(this).addClass("current");
    });
});
function login() {
    var username = document.getElementById("username").value;
    var password = document.getElementById("password").value;

    Parse.User.logIn(username, password, {
        success: function (user) {
            window.location = "charifyer.html"
        },
        error: function (user, error) {
            console.log("Error: " + error.code + " " + error.message);
        }
    });

    
}
function register() {
    var username = document.getElementById("usernameR").value;
    var password = document.getElementById("passwordR").value;
    var passRepeat = document.getElementById("passRepeat").value;
    var email = document.getElementById("email").value;

    if (password == passRepeat) {
        var user = new Parse.User();
        user.set("username", username);
        user.set("password", password);
        user.set("email", email);

        user.signUp(null, {
            success: function (user) {
                alert("Congratz! You are a part of our family now.");
                location.reload();
            },
            error: function (user, error) {
                console.log("Error: " + error.code + " " + error.message);
            }
        });
    }

    
}